<?php
/* @var $this MessageController */
/* @var $model Message */
/* @var $form CActiveForm */
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/js/jquery-plugins/chosen/chosen.jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        KindEditor.ready(function(K) {
            window.editor = K.create('#kindeditor');
        });
        //$("#Book_typeid").chosen({allow_single_deselect: true});
    });
</script>

<div class="form">

    <?php $form=$this->beginWidget('CActiveForm', array(
    	'id'=>'message-form',
    	// Please note: When you enable ajax validation, make sure the corresponding
    	// controller action is handling ajax validation correctly.
    	// There is a call to performAjaxValidation() commented in generated controller code.
    	// See class documentation of CActiveForm for details on this.
    	'enableAjaxValidation'=>false,
        'clientOptions' => array(
            'validateOnSubmit' => true,  //在这个位置做验证
        ),
        'focus' => array($model,'content'),
    )); ?>

	<?php echo $form->errorSummary($model); ?>

	<div class="top-margin">
		<?php echo $form->labelEx($model,'书名', array('class'=>'text-danger')); ?>
        <?php echo CHtml::dropDownList(
                'Message[bookid]',
                $model->bookid,
                CHtml::listData(Book::model()->findAll(),'id','bookname')
            ); ?>
		<?php echo $form->error($model,'bookid'); ?>
	</div>

    <!--
	<div class="row">
		<?php echo $form->labelEx($model,'userid'); ?>
		<?php echo $form->textField($model,'userid'); ?>
		<?php echo $form->error($model,'userid'); ?>
	</div>
    -->

    <div>
        <?php echo $form->labelEx($model,'content'); ?>
        <textarea name="Message[content]" id="kindeditor" class='form-control'><?php echo $model->content; ?></textarea>
    </div>

    <!--
	<div class="row">
		<?php echo $form->labelEx($model,'内容', array('class'=>'text-danger')); ?>
		<?php echo $form->textField($model,'content',array('size'=>45,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'content'); ?>
	</div>
    -->

    <!--
	<div class="row">
		<?php echo $form->labelEx($model,'time'); ?>
		<?php echo $form->textField($model,'time'); ?>
		<?php echo $form->error($model,'time'); ?>
	</div>
    -->

    <hr/>
	<div class="text-right">
        <?php echo CHtml::submitButton($model->isNewRecord ? '立即创建' : '保存修改', array('class'=>'btn btn-action')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
